home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / editors / mutt / me2s_pl7.zoo / mu_edit2 / mc2 / mmaux.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-26  |  2.7 KB  |  116 lines

  1. /*
  2.  * mmaux.c : the tokens MM don't know about
  3.  *  Craig Durland 6/87
  4.  */
  5.  
  6. /* Copyright 1990, 1991, 1992 Craig Durland
  7.  *   Distributed under the terms of the GNU General Public License.
  8.  *   Distributed "as is", without warranties of any kind, but comments,
  9.  *     suggestions and bug reports are welcome.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include <os.h>
  14.  
  15. extern int MMask_pgm;    /* in mm.c */
  16. extern char result[];    /* in mm.c */
  17.  
  18. #include "mm.h"
  19. extern uint8 *MMglobal_vars;
  20. extern MMDatum RV, TV;    /* in mm.c */
  21. void MMbitch();
  22.  
  23. main(argc,argv) char *argv[];
  24. {
  25.   extern int MMask_pgm;
  26.  
  27.   MMask_pgm = TRUE;
  28.  
  29.   MMinitialize();
  30.   MMload(argv[1],TRUE);    /* load and go */
  31.   exit(0);
  32. }
  33.  
  34. void MMset_hooks() {}            /* No hooks used by this stuff */
  35. void MMgc_external_objects() {}        /* No external objects */
  36.  
  37. MMaux_fcn(name) char *name; { return FALSE; }
  38. void MMxtoken(token) { MMbitch("Invalid Xtoken"); }
  39.  
  40. MMask(prompt,buf) char *prompt, *buf;
  41. {
  42.   printf("%s",prompt); gets(buf); return TRUE;
  43. }
  44.  
  45. void MMmsg(str) char *str; { puts(str); }
  46.  
  47. void MMbitch(msg) char *msg;
  48. { printf("PGM ABORT(%u): %s\n",decodepc(),msg); MMabort_pgm(2); }
  49.  
  50. void MMmoan(msg) char *msg; { puts(msg); }
  51.  
  52. /*************************************************************************
  53. ****************** pgm management ****************************************
  54. **************************************************************************/
  55.  
  56. typedef struct        /* programs */
  57. {
  58.   char *name;        /* ascii name of command */
  59.   maddr addr;        /* address of routine */
  60. } PGM;
  61.  
  62. #define PGMMAX 100
  63.  
  64. PGM pgms[PGMMAX];
  65. int pbsize = 0;
  66. static maddr codeblock;
  67.  
  68. maddr MMpgm_addr(n) { return pgms[n].addr; }
  69.  
  70. maddr pcat();
  71. decodepc() { return (int)(pcat() -codeblock); }
  72.  
  73.     /*  MMopen_code_file(name): open the code file.
  74.      *  name munged to contain name of opened file.
  75.      *  returns: ptr to opened file
  76.      */
  77. FILE *MMopen_code_file(name) char *name;
  78. {
  79.   return fopen(name,"rb");
  80. }
  81.  
  82. MMadd_pgm(name,tag,addr) char *name; maddr addr;
  83. {
  84.   if (pbsize >= PGMMAX) { MMmoan("pgm table OD"); return FALSE; }
  85.   pgms[pbsize].name = name; pgms[pbsize].addr = addr; pbsize++;
  86.   return TRUE;
  87. }
  88.  
  89. void MMblock_name(buf,fname) char *buf,*fname;    /* create the block name */
  90. {}
  91.  
  92. MMadd_block(name,code,global_vars, global_object_table,num_global_objects)
  93.   char *name; maddr code; uint8 *global_vars;
  94.   void *global_object_table; int num_global_objects;
  95. {
  96.   codeblock = code;
  97.   return 0;
  98. }
  99.  
  100.     /* Use binary search to find pgm
  101.      * returns index of token if found
  102.      * -1 if not found
  103.      */
  104. MMpgm_lookup(name) char *name;
  105. {
  106.   register int  j, lower=0, upper=pbsize-1, x;
  107.  
  108.   while (lower<=upper)
  109.   {
  110.     j = (lower+upper)/2;
  111.     if ((x = strcmp(name,pgms[j].name))>0) lower = j +1;
  112.     else if (x<0) upper = j -1; else return j;
  113.   }
  114.   return -1;
  115. }
  116.